home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / patchlib539.lha / patchlib / include / patch.i < prev    next >
Encoding:
Text File  |  1996-12-07  |  8.3 KB  |  226 lines

  1.     IFND LIBRARIES_PATCH_I
  2. LIBRARIES_PATCH_I SET 1
  3. **
  4. **    Filename:    libraries/patch.i
  5. **    Release:    5.0
  6. **    Date:        12.10.96
  7. **
  8. **    (C) Copyright 1993-96 Stefan Fuchs
  9. **    All rights reserved
  10. **
  11. **      definition of patch.library public structures, returncodes and macros
  12.  
  13.  
  14.     IFND EXEC_TYPES_I
  15.     include "exec/types.i"
  16.     ENDC
  17.  
  18.     IFND EXEC_LISTS_I
  19.     include "exec/lists.i"
  20.     ENDC
  21.  
  22.     IFND EXEC_LIBRARIES_I
  23.     include "exec/libraries.i"
  24.     ENDC
  25.  
  26.     IFND EXEC_SEMAPHORES_I
  27.     include "exec/semaphores.i"
  28.     ENDC
  29.  
  30. ;-------------------------------------------------------------------------
  31. ;ErrorCodes:
  32. PATERR_Ok        equ    0    ;Everything Ok
  33. PATERR_PatchInUse    equ    1    ;Patch Usecount <> 0
  34. PATERR_InvalidHandle    equ    2    ;Pointer to patch is not (no longer) valid
  35. PATERR_OutOfMem        equ    3    ;Out of memory
  36. PATERR_OpenLib        equ    4    ;Failed to open requested library
  37. PATERR_FuncNotStd    equ    5    ;Function to patch is not in the standard format
  38. PATERR_PatchInstalled    equ    6    ;Can't remove patch because another program has
  39.                     ;installed a non-patch.library patch later
  40. PATERR_InvalidTags    equ    7    ;There was an error in the combination of the specified Tags
  41. PATERR_OpenDev        equ    8    ;Failed to open requested device
  42. PATERR_NoTaskList    equ    9    ;PATT_AddTask... or PATT_RemTask... was specified for a patch,
  43.                     ;which had no PATT_CreateTaskList set
  44. PATERR_TaskListExists    equ    10    ;PATT_CreateTaskList was specified, but there already exists a TaskList
  45. PATERR_InvalidTaskList    equ    11    ;PATT_CreateTaskList was specified with a wrong parameter
  46. PATERR_PatchUnnamed    equ    12    ;PATT_PatchName with GetPatch was specified, for a patch without an IDString
  47. PATERR_NoSemaphore    equ    13    ;Could not allocate semaphore
  48.  
  49. PATERR_KickTooOld    equ    14    ;Kickstart version is too old for this function
  50. PATERR_InvalidPattern    equ    15    ;Pattern passed via PATT_AddTaskPattern is not valid
  51. PATERR_Restricted    equ    16    ;Certain tags/features may not be used when patching certain functions
  52.  
  53. ;-------------------------------------------------------------------------
  54.  STRUCTURE PatchNotifyMessage,0
  55.     STRUCT pnm_ExecMessage,MN_SIZE
  56.     ULONG  pnm_Class
  57.     UWORD  pnm_Code
  58.     APTR   pnm_Object
  59.     LABEL  PatchNotifyMessage_SIZEOF    ;Don't depend on this
  60.  
  61. ;-------------------------------------------------------------------------
  62. PATCHNOTIFY_CLASS    equ    $50000000
  63. ;-------------------------------------------------------------------------
  64. ;Notification codes (pnm_Code) (ignore messages with other codes):
  65. PATCOD_PatchInstalled    equ     1    ;new patch has been added
  66. PATCOD_PatchRemoved    equ    2    ;a patch has been removed
  67. PATCOD_PatchChanged    equ    3    ;attributes of a patch have been changed
  68.  
  69. ;-------------------------------------------------------------------------
  70.  STRUCTURE PatchXResult,0    ;Use PatchAlloc(PS_TYPE_XRESULT) to allocate this
  71.     STRUCT pxr_Node,LN_SIZE    ;Reserved
  72.     ULONG  pxr_RegPattern    ;Which of the following register fields are used (see below)
  73.     ULONG  pxr_RegD0
  74.     ULONG  pxr_RegD1
  75.     ULONG  pxr_RegD2
  76.     ULONG  pxr_RegD3
  77.     ULONG  pxr_RegD4
  78.     ULONG  pxr_RegD5
  79.     ULONG  pxr_RegD6
  80.     ULONG  pxr_RegD7
  81.     ULONG  pxr_RegA0
  82.     ULONG  pxr_RegA1
  83.     ULONG  pxr_RegA2
  84.     ULONG  pxr_RegA3
  85.     ULONG  pxr_RegA4
  86.     ULONG  pxr_RegA5
  87.     ULONG  pxr_RegA6
  88.     UWORD  pxr_FlowControl    ;What patches follow this one (see below)
  89.     LABEL  PatchXResult_SIZEOF    ;Don't depend on this
  90. ;-------------------------------------------------------------------------
  91. ;Valid values for per_FlowControl:
  92. PATFC_Normal        equ    0    ;No change in the sequnce of patchcodes
  93. PATFC_FallBack        equ    1    ;Use original function (only valid, if PATT_Priority is NULL)
  94. ;-------------------------------------------------------------------------
  95. ; Register definitions for obsolete PATT_SaveRegisters and pxr_RegPattern:
  96. PATREG_D0        equ $8000
  97. PATREG_D1        equ $4000
  98. PATREG_D2        equ $2000
  99. PATREG_D3        equ $1000
  100. PATREG_D4        equ $0800
  101. PATREG_D5        equ $0400
  102. PATREG_D6        equ $0200
  103. PATREG_D7        equ $0100
  104. PATREG_A0        equ $0080
  105. PATREG_A1        equ $0040
  106. PATREG_A2        equ $0020
  107. PATREG_A3        equ $0010
  108. PATREG_A4        equ $0008
  109. PATREG_A5        equ $0004
  110. PATREG_A6        equ $0002
  111. ;---------------------------------------------------------------
  112. PATCHNAME    MACRO
  113.     dc.b "patch.library",0
  114.     ENDM
  115.  
  116. ;---------------------------------------------------------------
  117. ;--- FALLBACK - Call this macro instead of a 'rts' instruction
  118. ;--- in your patchcode, if you want to return to the original
  119. ;--- library code
  120. ;--- WARNING: The FALLBACK macro may be replaced by a better solution in V5,
  121. ;--- and may eventually no longer work in later versions. Please E-Mail me,
  122. ;--- if you use the FALLBACK macro.
  123. ;--- Now this is the V5 release of patch.library! So you might wonder, why
  124. ;--- the macro is still here. The answer is simple. I got used to this little
  125. ;--- macro. So i'll keep it at least until V6 and likely even beyond.
  126. ;---------------------------------------------------------------
  127. FALLBACK    MACRO
  128.     move.l (sp),-(sp)
  129.     clr.l 4(sp)
  130.     rts
  131.  
  132.     ENDM
  133.  
  134. ;---------------------------------------------------------------
  135. ;--- GETPATCHBASE - Call this macro, if you need to call patch.library
  136. ;--- functions within a patchcode
  137. ;--- - DO NOT USE OUTSIDE A PATCHCODE
  138. ;--- - DO NOT USE, IF YOU PATCH EXEC.LIBRARY/FINDNAME()
  139. ;--- Returns patchbase in a6
  140. ;---------------------------------------------------------------
  141. GETPATCHBASE    MACRO
  142.     movem.l d0/d1/a0/a1,-(sp)
  143.     move.l 4.w,a6
  144.     move.l LibList(a6),a0
  145.     lea.l 2$(pc),a1
  146.     jsr -276(a6)        ;FindName
  147.     move.l d0,a6
  148.     movem.l (sp)+,d0/d1/a0/a1
  149.     bra 1$
  150. 2$    dc.b "patch.library",0
  151.     even
  152. 1$
  153.     ENDM
  154.  
  155.  
  156. ;----------------------------------------------------------------------------
  157. ;----------------------------------------------------------------------------
  158. ;The following structures are not needed by normal patch.library applications
  159. ;----------------------------------------------------------------------------
  160. ;----------------------------------------------------------------------------
  161.     STRUCTURE PatchBase,LIB_SIZE
  162.     UBYTE PB_Flags                ;see below
  163.     UBYTE PB_reserved1
  164.     ULONG PB_private1
  165.  
  166.     STRUCT    PB_Semaphore,SS_SIZE        ;Semaphore to protect MasterPatchList
  167.     STRUCT    PB_MasterPatchHeader,LH_SIZE    ;Listheader structure for MasterPatch structures
  168.  
  169.     ;...
  170.  
  171. ;PB_Flags:
  172.     BITDEF    PB,CheckPC,0        ;If TRUE: Enable safe removal of patches!
  173.                     ;Patch.library will use a hack, which
  174.                     ;is highly dependent on OS versions and installed
  175.                     ;processors and may therefore not work with
  176.                     ;certain configurations
  177.                     ;It's unlikely to crash the machine though
  178.                     ;New with V5, default: FALSE
  179.  
  180. ;-------------------------------------------------------------------------
  181. ; Before accessing this structure, make sure MPS_TYPE is PS_TYPE_MASTER
  182.  
  183.  STRUCTURE MasterPatch,0    ;This structure is READONLY
  184.     APTR    MPS_SUCC    ;Pointer to next (successor)
  185.     APTR    MPS_PRED    ;Pointer to previous (predecessor)
  186.     UBYTE    MPS_TYPE    ;MUST be PS_TYPE_MASTER
  187.     BYTE    MPS_PRI        ;Priority, for sorting
  188.     APTR    MPS_NAME    ;may contain a pointer to the name of the patched library
  189.                 ;To compensate the loss of a valid librarybase
  190.                 ;MPS_NAME is now (V4) guaranteed to contain a valid name
  191.                 ;this may however be a library, device or resource name
  192.     UWORD    MPS_Flags            ;no public flags defined
  193.     STRUCT    MPS_PatchHeader,MLH_SIZE    ;Listheader Structure for Patch structures
  194.     APTR    MPS_Private01            ;This pointer, up to V3 known as MPS_PatchedLibraryBase
  195.                         ;has been renamed, because with the introduction of the
  196.                         ;PatchSupervisor it may or may not contain a valid
  197.                         ;librarybase, it may even contain 0.
  198.     UWORD    MPS_PatchedLVO            ;Library Vector Offset in patched Library
  199.  
  200.     ;...
  201.  
  202. ;--------------------------------------------------------------------------
  203. ; Before accessing this structure, make sure PS_TYPE is either PS_TYPE_USER or PS_TYPE_SYSTEM
  204. ; Make sure your program can handle lists, that do not contain any nodes of
  205. ; PS_TYPE_USER or PS_TYPE_SYSTEM
  206.  
  207.  STRUCTURE Patch,0        ;This structure is READONLY
  208.     APTR    PS_SUCC        ;Pointer to next (successor)
  209.     APTR    PS_PRED        ;Pointer to previous (predecessor)
  210.     UBYTE    PS_TYPE        ;MUST be PS_TYPE_USER or PS_TYPE_SYSTEM
  211.     BYTE    PS_PRI        ;Priority, for sorting
  212.     APTR    PS_NAME        ;may contain a pointer to the name of the patch
  213.     UWORD    PS_Flags    ;no public flags defined
  214.  
  215.     ;...
  216.  
  217. ;-------------------------------------------------------------------------
  218. ;Public types of structures:
  219. PS_TYPE_MASTER    = 1    ;node is MasterPatch structure
  220. PS_TYPE_USER    = 2    ;node was installed by an application using the library interface
  221. PS_TYPE_SYSTEM    = 3    ;node was installed by the support program PatchSetFunc
  222. PS_TYPE_XRESULT    = 30    ;this struct is an PatchXResult structure
  223.  
  224.  
  225.     ENDC    ;LIBRARIES_PATCH_I
  226.